namespace C1.Win.C1FlexGrid
{
    using System;
    using System.Drawing;
    using System.Windows.Forms;

    internal class Marquee
    {
        private static Brush _br;
        private Control _ctl;
        private Rectangle _rc;

        internal Marquee(Control ctl)
        {
            this._ctl = ctl;
            this._rc = new Rectangle(0, 0, 0, 0);
            if (_br == null)
            {
                _br = new SolidBrush(Color.Black);
            }
        }

        internal void Reset()
        {
            this.Update(new Rectangle(0, 0, 0, 0));
        }

        internal void Update(Rectangle rc)
        {
            if (!this._rc.Equals(rc))
            {
                if ((this._rc.Width > 0) && (this._rc.Height > 0))
                {
                    this._ctl.Invalidate(this._rc);
                    this._ctl.Update();
                }
                if ((rc.Width > 0) && (rc.Height > 0))
                {
                    using (Graphics graphics = this._ctl.CreateGraphics())
                    {
                        graphics.FillRectangle(_br, rc);
                    }
                }
                this._rc = rc;
            }
        }
    }
}

